
#pragma once

#ifndef __SWIG__
#include <windows.h>
#include <map>

#endif

#define WINDOW_STYLE				WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
#define MUIBOX_STYLE				WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
#define WINDOW_STYLE_FULLSCREEN		WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX
#define WINDOW_STYLE_EX				WS_EX_APPWINDOW
#define WINDOW_THIN_STYLE			WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN

#ifdef __SWIG__
%include <typemaps.i>
%include "winTypes.i"
%apply SWIGTYPE* OUTPUT {RECT* outRect};
%apply int& OUTPUT {int& outX};
%apply int& OUTPUT {int& outY};

%typemap(in) (const char* muiClipInfo, UINT muiClipLen) {
	if (PyString_Check($input))
		$1 = (char*) PyString_AsString($input);
	else
		SWIG_exception(SWIG_TypeError, "string expected");
	$2 = PyString_Size($input);       /* int len   */
}


%typemap(in) (const WCHAR* files, UINT lens) {
	if (PyUnicode_Check($input))
		$1 = (WCHAR*) PyUnicode_AsUnicode($input);
	else
		SWIG_exception(SWIG_TypeError, "Unicode string expected");
	$1 = PyUnicode_AsUnicode($input);   /* char *str */
	$2 = PyUnicode_GetSize($input);       /* int len   */
}
#endif

#include "ExportSymbol.h"
class CBaseWnd 
{
#ifndef __SWIG__
protected:
	HWND m_hWnd;
	BOOL m_bFullScreen;
	DWORD			m_winStyle;
	DWORD			m_fullStyle;
	DWORD			m_winStyleEx;

	WINDOWPLACEMENT m_wpNormal;
	static std::map<HWND, void*> ms_windows;
protected:
	int m_preMouseX;
	int m_preMouseY;
	BOOL m_isMouseInWindow;
	//Cursor
	std::map<std::wstring, HCURSOR>	m_mapCursors;
	HCURSOR			m_hCurrentCursor;
	HCURSOR			m_hArror;
	HCURSOR			m_hCross;
	HCURSOR			m_hHand;
	HCURSOR			m_hQuery;
	HCURSOR			m_hDrop;
	HCURSOR			m_hSizeWE;
	HCURSOR			m_hSizeNS;
	HCURSOR			m_hSizeNWSE;
	HCURSOR			m_hSizeNESW;
	HCURSOR			m_hSizeAll;

protected:
	virtual HRESULT _GetWndClassName(WCHAR* wndClassName, UINT szSize, UINT wstyle);
	virtual HRESULT _CreateWindow(HWND hWndParent, UINT wndWidth, UINT wndHeight, HWND& hwnd, const WCHAR* pWndName, UINT classStyle,
						UINT windowStyle, UINT windowExStyle, int winPosX = CW_USEDEFAULT, int winPosY = CW_USEDEFAULT);
	virtual ATOM _RegisterWndClass(HINSTANCE hInstance, UINT wstyle);
	virtual HRESULT _TrackMouseLeave();

	virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	virtual WNDPROC GetWndProc();
	static LRESULT CALLBACK _WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

	////////parse wParam, lParam func  ///////
	virtual LRESULT _OnMouseMessage(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnKeyboardMessage(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnActivate(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnActivateApp(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnCreate(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnEnable(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnGetMinMaxInfo(UINT message, WPARAM wParam, LPARAM lParam);	
	virtual LRESULT _OnMove(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnMoving(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnNCActivate(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnQuit(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnNCCreate(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnShowWindow(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnSize(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnSizing(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnStyleChanged(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnStyleChanging(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnWindowPosChanged(UINT message, WPARAM wParam, LPARAM lParam);
	virtual LRESULT _OnWindowPosChanging(UINT message, WPARAM wParam, LPARAM lParam);
    //////////////////Message Callback////////
	virtual LRESULT OnMouseMessage(UINT message, int x, int y, int dx, int dy, int zDelta, int keyState);
	virtual LRESULT OnKeyboardMessage(UINT message, UINT nChar, UINT nRepCnt);
	virtual LRESULT OnActivate(UINT actType, BOOL bMinimize, long hwnd);
	virtual LRESULT OnActivateApp(BOOL bActivate, long hThread);
	virtual LRESULT OnClose();
	virtual LRESULT OnPaint();
	virtual LRESULT OnCreate(CREATESTRUCT* pCreateInfo);
	virtual LRESULT OnDestory();
	virtual LRESULT OnEnable(BOOL bEnable);
	virtual LRESULT OnEnterSizeMove();
	virtual LRESULT OnExitSizeMove();
	virtual LRESULT OnGetMinMaxInfo(MINMAXINFO* pInfo);
	virtual LRESULT OnMove(int x, int y);
	virtual LRESULT OnMoving(RECT* prect);
	virtual LRESULT OnNCActivate(BOOL bActivate, long hRgn);
	virtual LRESULT OnNCCreate(CREATESTRUCT* pCreateInfo);
	virtual LRESULT OnNCDestory();
	virtual LRESULT OnNullMessage();
	virtual LRESULT OnQuit(int nExitCode);
	virtual LRESULT OnCancelMode();
	virtual LRESULT OnQueryDragIcon();
	virtual LRESULT OnQueryOpen();
	virtual LRESULT OnShowWindow(BOOL bShow, UINT status);
	virtual LRESULT OnSize(UINT width, UINT height, UINT nFlag);
	virtual LRESULT OnSizing(RECT* pRect, UINT nFlag);
	virtual LRESULT OnStyleChanged(int styleType, STYLESTRUCT* pStyleInfo);
	virtual LRESULT OnStyleChanging(int styleType, STYLESTRUCT* pStyleInfo);
	virtual LRESULT OnThemeChanged();
	virtual LRESULT OnUserChanged();
	virtual LRESULT OnWindowPosChanged(WINDOWPOS* pwndPos);
	virtual LRESULT OnWindowPosChanging(WINDOWPOS* pwndPos);
	
	
#endif
public:
	CBaseWnd();
	~CBaseWnd();
	virtual HRESULT ResizeWindow(UINT width, UINT height);
	virtual HRESULT ShowWindow(UINT cmdShow);
	virtual int GetHwnd();
	virtual HRESULT Create(HWND hwndParent, UINT wndWidth, UINT wndHeight, const WCHAR* pWndName, UINT classStyle = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
		UINT windowStyle = WS_MINIMIZEBOX| WS_MAXIMIZEBOX | WS_OVERLAPPEDWINDOW , UINT windowExStyle = WS_EX_APPWINDOW | WS_EX_ACCEPTFILES | WS_EX_LAYERED, int winPosX = CW_USEDEFAULT, int winPosY = CW_USEDEFAULT);
	virtual HRESULT DestroyWindow();
	virtual BOOL IsWindowVisible();
	virtual BOOL GetWindowRect(RECT* outRect);
	virtual BOOL GetClientRect(RECT* outRect);
	virtual BOOL ScreenToClient(int& outX, int& outY, int x, int y);
	virtual BOOL ClientToScreen(int& outX, int& outY, int x, int y);
	virtual BOOL GetWindowText(WCHAR* OUTPUT_len512, int nOutMaxCount);
	virtual int GetWindowTextLength();
	virtual BOOL MoveWindow(int X, int Y, int nWidth, int nHeight, BOOL bRepaint);
	virtual long SetParent(long parentHwnd);
	virtual long GetParent();
	virtual BOOL CloseWindow();
	virtual BOOL UpdateWindow();
	virtual BOOL RedrawWindow(const RECT* lprcUpdate, long hrgn, UINT flags);
	virtual LONG SetWindowStyle(LONG wStyle);
	virtual BOOL SetLayeredWindowAttributes(float alpha);
	virtual BOOL SetCursor(WCHAR* strCursor);
	virtual BOOL LoadCursor(const WCHAR* name, const WCHAR* filename);
	virtual void SetCapture(BOOL bCapture);
	virtual BOOL EnableWindow(BOOL bEnable);
	virtual BOOL SetFocus();
	virtual void EnterMovingMode();
	virtual BOOL SetFullScreen(BOOL bFullScreen, BOOL bShow, BOOL bActivate);
	virtual BOOL IsFullScreen();
};